<?php
require_once ("db/db_connector.php");
require_once ("db/db_paradise.php");
require_once ("db/db_picture.php");
require_once("db/db_favorite.php");

// Database Access Begins ---------------------------------------- //
$con = get_db_con();
$paradise_list = get_my_paradise($con);
$tag_list = get_favorite_tags($con);
close_db_con();
// Database Access Ends ------------------------------------------ //
?>

<?php
include_once ("include/header.php");
?>

<div>
	<h2>Favorite Tags</h2>
	<table>
			<?php foreach($tag_list as $tag): ?>
				<tr>
					<td>
						<?=$tag["name"] ?>
					</td>
				</tr>
					<?php endforeach ?>

	</table>
		
	<h2>Paradise Over the World</h2>
	<table>
		<tr>
			<th>thumb_small</th>
			<th>name</th>
			<th>rating</th>
			<th>type</th>
			<th>climate_high</th>
			<th>climate_low</th>
			<th>continent</th>
			<th>language</th>
			<th>religion</th>
			<th>population</th>
			<th>gdp</th>
		</tr>
	<?php foreach ($paradise_list as $paradise): ?>
		<tr>
			<td>
            <?php
			if (is_null($paradise["picture_id"]))
				echo "NO ASSIGNED IMAGE";
			else {
				$con = get_db_con();
				$image = get_picture($con, $paradise["picture_id"]);
				echo "<img src=" . $image["thumb_small"] . "/>";
				close_db_con();
			}
            ?>
			</td>
			<td>
				<a href="paradise.php?id=<?=$paradise["id"] ?>">
					<?=$paradise["name"] ?>
				</a>
			</td>
			<td><?=$paradise["rating"] ?></td>
			<td><?=$paradise["type"] ?></td>
			<td><?=$paradise["climate_high"] ?></td>
			<td><?=$paradise["climate_low"] ?></td>
			<td><?=$paradise["continent"] ?></td>
			<td><?=$paradise["language"] ?></td>
			<td><?=$paradise["religion"] ?></td>
			<td><?=$paradise["population"] ?></td>
			<td><?=$paradise["gdp"] ?></td>
		</tr>
	<?php endforeach ?>
	</table>
</div>

<?php
include_once ("include/footer.php");
?>
